package com.neusoft.elmboot.controller;

import com.neusoft.elmboot.po.Business;
import com.neusoft.elmboot.service.BusinessService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.neusoft.elmboot.result.Result;

import java.util.List;

/**
 * 商家
 * Controller
 */
@RestController
@Slf4j
@RequestMapping(value = "/BusinessController")
public class BusinessController {

    @Autowired
    private BusinessService businessService;

    @RequestMapping(value = "/listBusiness")
    public Result<List<Business>> listBusiness() throws Exception{
        List<Business> businessList = businessService.listBusiness();
        log.info("调用接口：列出所有商家信息");
        return Result.success(businessList);
    }
    @RequestMapping(value = "/listBusinessByOrderTypeId")
    public Result<List<Business>> listBusinessByOrderTypeId(Business business) throws Exception{
        List<Business> businessList= businessService.listBusinessByOrderTypeId(business.getOrderTypeId());
        log.info("调用接口：根据类型列出商家信息");
        return Result.success(businessList);
    }
    @RequestMapping(value = "/getBusinessById")
    public Result<Business> getBusinessById(Business business) throws Exception{
        Business bus = businessService.getBusinessById(business.getBusinessId());
        log.info("调用接口：根据ID查询商家信息");
        return Result.success(bus);
    }
}
